ifeq ($(shell uname),Linux)
	OS = Linux
	ifneq (x86_64,$(shell uname -m))
		PLATFORM = 32
	else
		PLATFORM = 64
	endif
	ifneq (,$(shell cat /etc/*-release | grep Ubuntu))
		DISTRIB = Ubuntu
		RELEASE = $(shell cat /etc/*-release | grep RELEASE | sed -e "s/.*RELEASE=\(.*\)/\1/")
		MKSPEC = mkspecs/Ubuntu.mk
	endif
	ifneq (,$(shell cat /etc/*-release | grep Mint))
		DISTRIB = Mint
		RELEASE = $(shell cat /etc/*-release | grep RELEASE | sed -e "s/.*RELEASE=\(.*\)/\1/")
		MKSPEC = mkspecs/Ubuntu.mk
	endif
	ifneq (,$(shell cat /etc/*-release | grep "Red Hat Enterprise Linux"))
		DISTRIB = RHEL
		RELEASE = $(shell cat /etc/*-release | head -n1 | sed -e "s/.*\([0-9]\.[0-9]\).*/\1/")
		MKSPEC = mkspecs/RHEL.mk
	endif
	ifneq (,$(shell cat /etc/*-release | grep "CentOS"))
		DISTRIB = RHEL
		RELEASE = $(shell cat /etc/*-release | sed -e "s/release \(.\)/\1/")
		MKSPEC = mkspecs/RHEL.mk
	endif
	ifeq (,${DISTRIB})
		$(error Unsupported architecture $(shell cat /etc/*-release))
	endif
else
	OS = Win
	DEFINES += ISWIN
    CLEAN_TARGETS += *.pdb
	PLATFORM = $(shell cl 2>&1 | grep Version | sed -e "s/.*\([0-9][0-9]\)-bit.*/\1/")
	DISTRIB = .NET
	RELEASE = $(shell cl 2>&1 | grep Version | sed -e "s/.*Version \([0-9][0-9]\).*/\1/")
	ifeq (13,${RELEASE})
		RELEASE = 2003
	endif
	ifeq (14,${RELEASE})
		RELEASE = 2005
	endif
	ifeq (15,${RELEASE})
		RELEASE = 2008
	endif
	ifeq (16,${RELEASE})
		RELEASE = 2010
	endif
	MKSPEC = mkspecs/MSVC.mk
endif
ARCH = #${OS}${PLATFORM}${DISTRIB}${RELEASE}

debug?=no
ifeq (${debug},no)
	OBJDIR = bin/${ARCH}/Release
else
	OBJDIR = bin/${ARCH}/Debug
endif
BINDIR = ${OBJDIR}
